<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="box" class="box1" data-aaa="aa"></div>
    <script>   
        box.setAttribute('class','box1 box2');
        console.log(box.getAttribute('class'));
        console.log(box.dataset.aaa);
        box.dataset.aaa = 'bbb';
        console.log(box.dataset.aaa);
        box.dataset.bbb = 'bbb';
        console.log(box.dataset.bbb);





    </script>
    
</body>
</html>